<template>
    <div>
        <common-index :showTab="m_showTab" :configs="layoutConfigs" :layoutActiveTab="v_activeName" @change-tab="m_changeTab">
            <keep-alive>
                <component :is="v_activeName" :ref="v_activeName" />
            </keep-alive>
        </common-index>
        <!-- 综合查询侧滑框 -->
        <integratedQuery :dictionary="m_moduleList" />
    </div>
</template>

<script lang="ts">
// import Vue from 'vue'
import Component, { mixins } from 'vue-class-component';
import { layoutConfigs, tabsConfig, listConfig } from './configs/index';
import indexMixins from '@/mixins/index-mixins';
import registVuexModuleMixins from './configs/registVuex-module';
// import vuexMixins from './configs/vuex-module'
import vuexMixins from '@/mixins/vuex-modulel-mixins';
import apiUrl from '@/api/config-center/channelOrganization';
import { nest } from '@/utils';
import { Tools } from '@/utils/tools';
@Component({
    name: 'router-120001',
    components: {
        list: () => import('./list.vue'),
        detail: () => import('./detail.vue'),
        integratedQuery: () => import('@/components/integrated-query/index.vue'),
        commonIndex: () => import('@/layout-components/common-index/index.vue')
    }
})
export default class App extends mixins(indexMixins, vuexMixins, registVuexModuleMixins) {
    layoutConfigs = layoutConfigs;

    created() {
        this.getDropDown();
    }
    /**
     * 获得渠道全部下拉
     */
    async getDropDown() {
        const res = await this._get({
            url: apiUrl.getDropDown
        });

        if (res.code === 0) {
            const data = res.data;
            const channelProperties = tabsConfig.channelProperties;
            // const highSearchDialogFromlist = highSearchDialog.formList
            const financialInformation = tabsConfig.financialInformation;
            const salePolicy = tabsConfig.salePolicy;
            const listForm = listConfig.formList;

            const actions = new Map<any, any>([
                [
                    ['areaTreeList', 'commodityCategorySettingList', 'organizationTreeList'],
                    (val, keys) => {
                        const nestResult = nest(val, 0, 'parentId', false) || [];
                        Tools.setValueAndName(nestResult);
                        Tools.setOptions(nestResult, keys, channelProperties);
                        Tools.setOptions(nestResult, keys, listForm);
                        // Tools.setOptions(nestResult, keys, highSearchDialogFromlist)
                    }
                ],
                [
                    [
                        'businessNatureList',
                        'legalPersonList',
                        'fundAccountList',
                        'parentChannelList',
                        'branchCompanyList',
                        'balanceTypeList',
                        'tagPriceTypeList',
                        'salesAreaList',
                        'priceTypeList',
                        'brandList',
                        'gradeList',
                        'businessFormatList'
                    ],
                    (val, keys) => {
                        Tools.setValueAndName(val);
                        Tools.setOptions(val, keys, channelProperties);
                        Tools.setOptions(val, keys, financialInformation);
                        // Tools.setOptions(val, keys, highSearchDialogFromlist)
                        Tools.setOptions(val, keys, salePolicy);
                    }
                ],
                ['default', () => {}]
            ]);
            for (const k in data) {
                actions.forEach((value, keys) => {
                    const action: any = keys.includes(k) ? value : actions.get('default');
                    action.call(this, data[k] || [], k);
                });
            }
        }
    }
}
</script>
